package cn.yunhe.shop;

import java.net.Socket;

public class OrderServer implements IorderServer {

	@Override
	public String getOrderInfo(String orderId)  {
		String reponseData = "";
		try {
			Socket client = new Socket("127.0.0.1",8080);
			//服务器端的包   类  方法 的参数和类型
			String packageName = "cn.yunhe.shop/r/n";
			String className = "OrderServer/r/n";
			String method = "getOrderInfo/r/n";
			String argVal = "NO:007/r/n";
			//编码  往通道中写入这4个值
			client.getOutputStream().write(packageName.getBytes());
			client.getOutputStream().write(className.getBytes());
			client.getOutputStream().write(method.getBytes());
			client.getOutputStream().write(argVal.getBytes());
			
			client.shutdownOutput();
			//获取服务器返回的值
			byte[] b = new byte[1];
			while(client.getInputStream().read(b)!=-1) {
				reponseData = reponseData + new String(b);
			}
			
			System.out.println("服务器端返回的值："+reponseData);
			
		} catch (Exception e) {
			// TODO: handle exception
		}
		return  reponseData;
		
	}

	@Override
	public String getOrderInfo2(String orderId) {
		// TODO Auto-generated method stub
		return null;
	}

}
